$(function () {


    $('#weixin').mouseover(function () {
        $('#weixinimg').css('display','block');
    })
    $('#weixin').mouseout(function () {
        $('#weixinimg').css('display','none');
    })


    $('#text').focus(function () {
        $('#text').val('')
    })
    $('#btn').focus(function () {
        this.blur()
    });



    //购物车
    $('#shopping').mouseover(function () {
        $('#shopping').css('color','#c1383e');
        $('#shopping').css('background','snow');
        $('#shopping').css('border','1px solid #c1383e');
        $('#shopping-cart').css('display','block')
    });
    $('#shopping-cart').mouseleave(function () {
        $('#shopping-cart').css('display','none')
        $('#shopping').css('background','#c1383e');
        $('#shopping').css('color','snow');

    });

    //下拉动画
    $('.down-d > a').hover(
        function () {
            var num = $(this).next().children().children().last().index();
            var hei = num * 35
            console.log(num)
            $(this).next().children().animate({height: hei},500);
            $(this).next().children().css('border-top','5px solid #c1383e');
        },
        function () {
            $(this).next().children().animate({height:'0'},500);
            $(this).next().children().animate({borderTop:'0'},500);

        });

    //轮播图
    var c = 0;
    var time = null
    function auto(){
        time = setInterval(function () {
            c++
            c = c==5?0:c;
            console.log(c)

            $('.roll img').eq(c).fadeIn(400).siblings('img').fadeOut(400);
            $('.roll ul li').eq(c).css('background','red').siblings('li').css('background','snow');
        },2000);
    }
    auto()

    $('.roll img').mouseenter(function () {
        clearInterval(time);
    });
    $('.roll img').mouseleave(function () {
        auto()
    });

    $('.roll ul li').mouseenter(function () {
        c = $(this).index();
        $('.roll img').eq(c).fadeIn(400).siblings('img').fadeOut(400);
        $('.roll ul li').eq(c).css('background','red').siblings('li').css('background','snow');
    });

    $('#next-right').click(function () {
        clearInterval(time);
        console.log(c);
        c++
        c = c == 5 ? 0 : c;
        $('.roll img').eq(c).fadeIn(400).siblings('img').fadeOut(400);
        $('.roll ul li').eq(c).css('background','red').siblings('li').css('background','snow');
    });

    $('#next-left').click(function () {
        clearInterval(time);
        console.log(c)
        c--;
        c = c < 0 ? 4 : c;
        $('.roll img').eq(c).fadeIn(400).siblings('img').fadeOut(400);
        $('.roll ul li').eq(c).css('background', 'red').siblings('li').css('background', 'snow');
    })



});